* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Helvetica', 'Arial', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #f0f0f0;
    padding: 20px;
}

.gameboy {
    width: 320px;
    background-color: #c0c0c0;
    border-radius: 15px 15px 50px 15px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3),
        inset 0 0 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    border: 2px solid #a0a0a0;
    position: relative;
}

/* 添加做旧纹理效果 */
.gameboy::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(45deg,
            rgba(255, 255, 255, 0.05) 25%,
            transparent 25%,
            transparent 75%,
            rgba(255, 255, 255, 0.05) 75%),
        linear-gradient(135deg,
            rgba(0, 0, 0, 0.03) 25%,
            transparent 25%,
            transparent 75%,
            rgba(0, 0, 0, 0.03) 75%);
    background-size: 150px 150px;
    pointer-events: none;
    opacity: 0.4;
    border-radius: 15px 15px 50px 15px;
}

/* 修改游戏机顶部样式 */
.gameboy-top {
    height: 30px;
    background-color: #b8b8b8;
    display: flex;
    align-items: center;
    padding: 0 15px;
    position: relative;
    border-bottom: 1px solid #999;
    box-shadow: inset 0 -2px 5px rgba(0, 0, 0, 0.1);
}

/* 修改游戏机主体部分 */
.gameboy-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, #c0c0c0, #b8b8b8);
}

/* 添加磨损效果的类 */
.worn-edges {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 40%,
            rgba(255, 255, 255, 0.1) 0%,
            transparent 60%);
    pointer-events: none;
    opacity: 0.6;
    border-radius: 15px 15px 50px 15px;
}

.power-light {
    width: 8px;
    height: 8px;
    background-color: #ff0000;
    border-radius: 50%;
    margin-right: 10px;
}

.logo {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.gameboy-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.screen-area {
    width: 250px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.screen-border {
    width: 220px;
    height: 200px;
    background-color: #444;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 5px;
    /* 增加屏幕边框的立体感 */
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
    border: 2px solid #333;
}

.screen {
    width: 200px;
    height: 180px;
    background-color: #9bbc0f;
    border-radius: 5px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 添加高光效果 */
    box-shadow: inset 2px 2px 5px rgba(255, 255, 255, 0.2),
        inset -2px -2px 5px rgba(0, 0, 0, 0.1);
}

/* 添加一个额外的高光层 */
.screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 0.1) 0%,
            rgba(255, 255, 255, 0) 100%);
    border-radius: 5px 5px 0 0;
    pointer-events: none;
}

#gameCanvas {
    width: 160px;
    height: 144px;
    image-rendering: pixelated;
}

#gameOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 16px;
    font-weight: bold;
}

.hidden {
    display: none !important;
}

.nintendo-text {
    font-size: 12px;
    font-style: italic;
    color: #333;
    align-self: flex-end;
    margin-right: 20px;
}

.controls {
    width: 100%;
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
}

/* 调整方向键尺寸 */
.d-pad {
    width: 90px;
    /* 从100px减小到90px */
    height: 90px;
    /* 从100px减小到90px */
    position: relative;
    background-color: #b0b0b0;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 -2px 4px rgba(255, 255, 255, 0.3);
    border: 1px solid #999;
}

.d-pad-btn {
    width: 28px;
    /* 从30px减小到28px */
    height: 28px;
    /* 从30px减小到28px */
    background-color: #444;
    border: none;
    color: #c0c0c0;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: 1px solid #333;
}

/* 调整十字键位置以适应新尺寸 */
.d-pad-btn.up {
    top: 0;
    left: 31px;
    /* 调整居中位置 */
    border-radius: 5px 5px 0 0;
}

.d-pad-btn.left {
    top: 31px;
    /* 调整居中位置 */
    left: 0;
    border-radius: 5px 0 0 5px;
}

.d-pad-btn.right {
    top: 31px;
    /* 调整居中位置 */
    right: 0;
    border-radius: 0 5px 5px 0;
}

.d-pad-btn.down {
    bottom: 0;
    left: 31px;
    /* 调整居中位置 */
    border-radius: 0 0 5px 5px;
}

.d-pad-center {
    width: 28px;
    /* 从30px减小到28px */
    height: 28px;
    /* 从30px减小到28px */
    background-color: #444;
    position: absolute;
    top: 31px;
    /* 调整居中位置 */
    left: 31px;
    /* 调整居中位置 */
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
    border-radius: 5px;
}

/* 调整AB按钮位置，向上移动 */
.action-buttons {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    transform: rotate(-25deg);
    margin-top: -10px;
    /* 向上移动10px */
}

/* 确保菜单按钮不超出游戏机本体 */
.menu-buttons {
    position: relative;
    /* 从absolute改为relative */
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    /* 添加上边距 */
    margin-bottom: 10px;
    /* 添加下边距，确保不会超出底部 */
}

.action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    margin: 5px 10px;
    /* 调整水平间距 */
    font-weight: bold;
    color: white;
    cursor: pointer;
    /* 增加按钮立体感 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 -2px 4px rgba(255, 255, 255, 0.3);
    border: 2px solid #cc0000;
}

.action-btn.a {
    background-color: #ff0000;
}

.action-btn.b {
    background-color: #ff0000;
}

.action-btn:active {
    transform: scale(0.95);
    /* 按下时的效果 */
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.menu-buttons {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    gap: 20px;
}

/* 删除冲突的菜单按钮定义，保留一个清晰的定义 */
.menu-buttons {
    position: relative;
    display: flex;
    justify-content: center;
    /* 左右居中 */
    gap: 10px;
    /* 减小按钮间距 */
    margin-top: 30px;
    /* 增加上边距，让按钮往下移 */
    margin-bottom: 10px;
    width: 100%;
    /* 确保宽度占满父容器，便于居中 */
    margin-left: 0;
    /* 重置左边距 */
    margin-right: 0;
    /* 重置右边距 */
}

/* 修改菜单按钮样式 */
.menu-btn {
    width: 60px;
    height: 20px;
    background-color: #444;
    border: none;
    border-radius: 15px;
    color: #c0c0c0;
    font-size: 10px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: 1px solid #333;
}

.menu-btn:active {
    background-color: #222;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
    transform: translateY(1px);
}

/* 将分数显示移到游戏机外部 */
.score-display {
    margin-top: 10px;
    font-size: 14px;
    color: #333;
    text-align: center;
    background-color: #fff;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 320px;
}

.instructions {
    max-width: 320px;
    margin-top: 20px;
    padding: 15px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.instructions h3 {
    margin-bottom: 10px;
    color: #333;
}

.instructions p {
    margin: 5px 0;
    color: #555;
}

@media (max-width: 400px) {
    .gameboy {
        width: 300px;
    }

    .screen-area {
        width: 230px;
    }

    .screen-border {
        width: 200px;
        height: 180px;
    }

    .screen {
        width: 180px;
        height: 160px;
    }
}